package com.jozen.modelbase.netwoek.util;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

public class IntentUtil {

    public static void toNextPage(Context mContext, Class cls) {
        Intent intent = new Intent(mContext, cls);
        mContext.startActivity(intent);
    }

    public static void toNextPageForResult(Activity activity, Class cls, int code) {
        Intent intent = new Intent(activity, cls);
        activity.startActivityForResult(intent, code);
    }

    public static void toNextPageForResultWithBundle(Activity activity, Class cls, Bundle bundle, int code) {
        Intent intent = new Intent(activity, cls);
        intent.putExtras(bundle);
        activity.startActivityForResult(intent, code);
    }

    public void toNextPageWithBundle(Context mContext, Class cls, Bundle bundle) {
        Intent intent = new Intent(mContext, cls);
        intent.putExtras(bundle);
        mContext.startActivity(intent);
    }

    //选择本地文件
    public static void selectLocalFile(Activity activity, int requestCode) {
        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.setType("*/*");//无类型限制
        //intent.setType(“image/*”);//选择图片
        //intent.setType(“audio/*”); //选择音频
        //intent.setType(“video/*”); //选择视频 （mp4 3gp 是android支持的视频格式）
        //intent.setType(“video/*;image/*”);//同时选择视频和图片
        activity.startActivityForResult(intent, requestCode);
    }

    //选择本地图片
    public static void selectLocalImage(Activity activity, int requestCode) {
        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.setType("image/*");//选择图片
        activity.startActivityForResult(intent, requestCode);
    }

}
